home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / prog_c / cuj0896.zip / KREHBIEL.ZIP / CHECK.C next >
C/C++ Source or Header  |  1996-04-15  |  3KB  |  97 lines

  1. Listing 3:
  2. /*--------------------------------------------------------------
  3.   check.c         check.exe entry point               1.0
  4. ----------------------------------------------------------------
  5.  
  6.   Program:    reports current system's VESA VBE capabilities.
  7.  
  8.   Build:    check.c,vbe.c,vbe.h --> check.exe
  9.  
  10.   Platform:    IBMPC,MSDOS.
  11.  
  12.   Functions:  
  13.     main        Display VESA VBE information.
  14.       ListModes    Display info on VESA Super VGA VideoModePtr.
  15.         
  16.   Edit history:
  17.     4/9/96    C.Krehbiel. Implemented check.c in MSVC 1.0 for 
  18.             IBMPC compatible platforms.
  19.             
  20. --------------------------------------------------------------*/
  21.  
  22. #include <stdio.h>
  23. #include <string.h>
  24.  
  25. #include <conio.h>
  26.  
  27. #include "vbe.h"    /* vesa vbe interface */
  28.  
  29. /*--------------------------------------------------------------
  30.                          local functions            
  31. --------------------------------------------------------------*/
  32. static void ListModes(int far *p)
  33.  
  34.     /* reports on each of the svga modes on the ModeListPtr (p)
  35.     returned by the vbe. */
  36. {
  37.     static ModeInfo_t info;
  38.     static const char *Text[]=
  39.     {
  40.         "Text mode","CGA graphics","Hercules","Planar",
  41.         "Packed pixel","Planar 256","Direct color","YUV",
  42.         "Unknown"
  43.     };
  44.     
  45.     puts("Mode\tMemory Model\tWinA\tWinB\tWindow\tResolution");
  46.     for(;*p>0;p++)
  47.     {
  48.         if(!VbeGetModeInfo(*p,&info)) continue;
  49.  
  50.         printf("%3Xh\t",*p);
  51.         printf("%-12.12s\t",
  52.             (info.MemoryModel>7?Text[7]:Text[info.MemoryModel]));
  53.         printf("%04Xh\t",info.WinASegment);
  54.         printf("%04Xh\t",info.WinBSegment);
  55.         printf("%d/%d\t",info.WinGranularity,info.WinSize);
  56.         printf("%dx%dx",info.XResolution,info.YResolution);
  57.         
  58.         if(!(info.ModeAttributes&8)) putchar('1');
  59.         else if(info.BitsPerPixel>16) 
  60.             printf("%dM",1<<info.BitsPerPixel-20);
  61.         else if(info.BitsPerPixel>8) 
  62.             printf("%dK",1<<info.BitsPerPixel-10);
  63.         else printf("%d",1<<info.BitsPerPixel);
  64.         
  65.         if(!(info.ModeAttributes&1)) printf(" (unavailable)");
  66.         
  67.         putchar('\n');
  68.     }
  69. }
  70. void main()
  71.  
  72.     /* reports on the current vbe implementation and uses 
  73.     ListModes() to report on vesa mode information. */
  74. {
  75.     static VbeInfo_t vbe;
  76.  
  77.     if(VbeGetVbeInfo(&vbe)) 
  78.     {
  79.         printf("%.4s ",vbe.VbeSignature);
  80.         printf("%d.%d ",
  81.             (vbe.VbeVersion>>8)&0xff,vbe.VbeVersion&0xff);
  82.         printf("%Fs\n",vbe.OemStringPtr);
  83.         if(vbe.TotalMemory<0x10) 
  84.             printf("%dK",vbe.TotalMemory<<6);
  85.         else printf("%dMB",vbe.TotalMemory>>4);
  86.         puts(" video memory installed.");
  87.         
  88.         ListModes(vbe.VideoModePtr);
  89.     }
  90.     else puts("VESA not detected.");
  91.  
  92. }
  93. /*--------------------------------------------------------------
  94.                                eof
  95. --------------------------------------------------------------*/
  96.  
  97.